<html>

    <h3>Planilha GIAH competencia <?php echo substr($competenciaativa, 0,4) . '/'.  substr($competenciaativa, 4,6)?></h3>
    <table border="1" >
        <thead>
            <tr>

                <th><font size="-2">Matr&iacute;cula</font></th>
                <th><font size="-2">Nome</font></th>
                <th><font size="-2">Fun&ccedil;&atilde;o</font></th>
                <th><font size="-2">Sal&aacute;rio base</font></th>
                <th>&nbsp;</th>
            </tr>

            <?
            $grupo = "";
            $totalvalor = 0;
                 foreach ($lista as $item) {
                     
                     if ($grupo == $item->classificacao || $grupo == '') {
            ?>
                 <tr>
                    <td><font size="-2"><?php echo $item->matricula; ?></font></td>
                    <td><font size="-2"><?php echo $item->nome; ?></font></td>
                    <td><font size="-2"><?php echo $item->classificacao; ?></font></td>
                    <td><font size="-2">R$ <?php echo  number_format($item->salario_base, 2, ",", "."); ?></font></td>
                    <td><font size="-2">__________</td>
                 </tr>

            <?
            $totalvalor = $totalvalor + $item->salario_base;
            } else {
            ?>
                    <tr bgcolor ="gray">
                    <td><font size="-2">TOTAL</font></td>
                    <td><font size="-2"></font></td>
                    <td><font size="-2"></font></td>
                    <td><font size="-2">R$ <?php echo  number_format($totalvalor, 2, ",", "."); ?></font></td>
                    <td><font size="-2">__________</td>
                 </tr>
                 
                                  <tr>
                    <td><font size="-2"><?php echo $item->matricula; ?></font></td>
                    <td><font size="-2"><?php echo $item->nome; ?></font></td>
                    <td><font size="-2"><?php echo $item->classificacao; ?></font></td>
                    <td><font size="-2">R$ <?php echo  number_format($item->salario_base, 2, ",", "."); ?></font></td>
                    <td><font size="-2">__________</td>
                 </tr>
                 <?
                 $totalvalor = 0;
            }

            $grupo = $item->classificacao;
                 }
            ?>
                                    
                    <tr bgcolor ="gray">
                    <td><font size="-2">TOTAL</font></td>
                    <td><font size="-2"></font></td>
                    <td><font size="-2"></font></td>
                    <td><font size="-2">R$ <?php echo  number_format($totalvalor, 2, ",", "."); ?></font></td>
                    <td><font size="-2">__________</td>
                 </tr>
                 
    </table>